itk_module_test()
set(
  ITKDenoisingTests
  itkPatchBasedDenoisingImageFilterTest.cxx
  itkPatchBasedDenoisingImageFilterDefaultTest.cxx
)

createtestdriver(ITKDenoising "${ITKDenoising-Test_LIBRARIES}" "${ITKDenoisingTests}")

itk_add_test(
  NAME itkPatchBasedDenoisingImageFilterDefaultTest
  COMMAND
    ITKDenoisingTestDriver
    --compare
    DATA{Baseline/PatchBasedDenoisingImageFilterDefaultTest.mha}
    ${ITK_TEST_OUTPUT_DIR}/PatchBasedDenoisingImageFilterDefaultTest.mha
    itkPatchBasedDenoisingImageFilterDefaultTest
    DATA{Input/noisy_checkerboard.mha}
    ${ITK_TEST_OUTPUT_DIR}/PatchBasedDenoisingImageFilterDefaultTest.mha
    2
)
itk_add_test(
  NAME itkPatchBasedDenoisingImageFilterTest0
  COMMAND
    ITKDenoisingTestDriver
    --compareRadiusTolerance
    2
    --compareIntensityTolerance
    15
    --compare
    DATA{Baseline/PatchBasedDenoisingImageFilterTest0.mha}
    ${ITK_TEST_OUTPUT_DIR}/PatchBasedDenoisingImageFilterTest0.mha
    itkPatchBasedDenoisingImageFilterTest
    DATA{Input/noisy_checkerboard.mha}
    ${ITK_TEST_OUTPUT_DIR}/PatchBasedDenoisingImageFilterTest0.mha
    2
    1
    14.093142951003070
    0
    0
    2
    2
    200
)
itk_add_test(
  NAME itkPatchBasedDenoisingImageFilterTestGaussian
  COMMAND
    ITKDenoisingTestDriver
    --compareRadiusTolerance
    2
    --compareIntensityTolerance
    15
    --compare
    DATA{Baseline/PatchBasedDenoisingImageFilterTestGaussian.mha}
    ${ITK_TEST_OUTPUT_DIR}/PatchBasedDenoisingImageFilterTestGaussian.mha
    itkPatchBasedDenoisingImageFilterTest
    DATA{Input/checkerboard_noise10Gaussian.mha}
    ${ITK_TEST_OUTPUT_DIR}/PatchBasedDenoisingImageFilterTestGaussian.mha
    2
    1
    14.418708309529121
    0
    0
    2
    2
    200
    0
    1
    GAUSSIAN
    0.1
)
itk_add_test(
  NAME itkPatchBasedDenoisingImageFilterTestRician
  COMMAND
    ITKDenoisingTestDriver
    --compareRadiusTolerance
    2
    --compareIntensityTolerance
    15
    --compare
    DATA{Baseline/PatchBasedDenoisingImageFilterTestRician.mha}
    ${ITK_TEST_OUTPUT_DIR}/PatchBasedDenoisingImageFilterTestRician.mha
    itkPatchBasedDenoisingImageFilterTest
    DATA{Input/checkerboard_noise10Rician.mha}
    ${ITK_TEST_OUTPUT_DIR}/PatchBasedDenoisingImageFilterTestRician.mha
    2
    1
    12.283962106667094
    0
    0
    2
    2
    200
    0
    1
    RICIAN
    0.1
)
itk_add_test(
  NAME itkPatchBasedDenoisingImageFilterTestPoisson
  COMMAND
    ITKDenoisingTestDriver
    --compareRadiusTolerance
    3
    --compareIntensityTolerance
    8
    --compare
    DATA{Baseline/PatchBasedDenoisingImageFilterTestPoisson.mha}
    ${ITK_TEST_OUTPUT_DIR}/PatchBasedDenoisingImageFilterTestPoisson.mha
    itkPatchBasedDenoisingImageFilterTest
    DATA{Input/checkerboard_noise10Poisson.mha}
    ${ITK_TEST_OUTPUT_DIR}/PatchBasedDenoisingImageFilterTestPoisson.mha
    2
    1
    9.9250532200729378
    0
    0
    2
    2
    200
    0
    1
    POISSON
    0.1
)
# Extra tolerance for Tensors. The alternative EigenValues-computation of this class is faster,
# but numerically unstable. The extra tolerance covers the difference between 64 and 32 bits machines.
itk_add_test(
  NAME itkPatchBasedDenoisingImageFilterTestTensors
  COMMAND
    ITKDenoisingTestDriver
    --compareNumberOfPixelsTolerance
    10
    --compare
    DATA{Baseline/PatchBasedDenoisingImageFilterTestTensors.nrrd}
    ${ITK_TEST_OUTPUT_DIR}/PatchBasedDenoisingImageFilterTestTensors.nrrd
    itkPatchBasedDenoisingImageFilterTest
    DATA{Input/noisyDiffusionTensors.nrrd}
    ${ITK_TEST_OUTPUT_DIR}/PatchBasedDenoisingImageFilterTestTensors.nrrd
    2
    6
    5.4377394641246628
    0
    0
    2
    2
    100
    0
    2
)
